using System;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;

public static class MoPubLog
{
	public static class SdkLogEvent
	{
		public const string InitStarted = "SDK initialization started";

		public const string InitFinished = "SDK initialized and ready to display ads.  Log Level: {0}";
	}

	public static class ConsentLogEvent
	{
		public const string Updated = "Consent changed to {0} from {1}: PII can{2} be collected.";

		public const string LoadAttempted = "Attempting to load consent dialog";

		public const string LoadSuccess = "Consent dialog loaded";

		public const string LoadFailed = "Consent dialog failed: {0}";

		public const string ShowAttempted = "Consent dialog attempting to show";

		public const string ShowSuccess = "Sucessfully showed consent dialog";
	}

	public static class AdLogEvent
	{
		public const string LoadAttempted = "Attempting to load ad";

		public const string LoadSuccess = "Ad loaded";

		public const string LoadFailed = "Ad failed to load: ({0}) {1}";

		public const string ShowAttempted = "Attempting to show ad";

		public const string ShowSuccess = "Ad shown";

		public const string Tapped = "Ad tapped";

		public const string Expanded = "Ad expanded";

		public const string Collapsed = "Ad collapsed";

		public const string Dismissed = "Ad did disappear";

		public const string ShouldReward = "Ad should reward user with {0} {1}";

		public const string Expired = "Ad expired since it was not shown fast enough";
	}

	private static readonly Dictionary<string, MoPubBase.LogLevel> logLevelMap = new Dictionary<string, MoPubBase.LogLevel>
	{
		{
			"SDK initialization started",
			MoPubBase.LogLevel.MPLogLevelDebug
		},
		{
			"SDK initialized and ready to display ads.  Log Level: {0}",
			MoPubBase.LogLevel.MPLogLevelInfo
		},
		{
			"Consent changed to {0} from {1}: PII can{2} be collected.",
			MoPubBase.LogLevel.MPLogLevelDebug
		},
		{
			"Attempting to load consent dialog",
			MoPubBase.LogLevel.MPLogLevelDebug
		},
		{
			"Consent dialog loaded",
			MoPubBase.LogLevel.MPLogLevelDebug
		},
		{
			"Consent dialog failed: {0}",
			MoPubBase.LogLevel.MPLogLevelDebug
		},
		{
			"Consent dialog attempting to show",
			MoPubBase.LogLevel.MPLogLevelDebug
		},
		{
			"Sucessfully showed consent dialog",
			MoPubBase.LogLevel.MPLogLevelDebug
		},
		{
			"Attempting to load ad",
			MoPubBase.LogLevel.MPLogLevelInfo
		},
		{
			"Ad loaded",
			MoPubBase.LogLevel.MPLogLevelInfo
		},
		{
			"Ad failed to load: ({0}) {1}",
			MoPubBase.LogLevel.MPLogLevelInfo
		},
		{
			"Attempting to show ad",
			MoPubBase.LogLevel.MPLogLevelInfo
		},
		{
			"Ad shown",
			MoPubBase.LogLevel.MPLogLevelInfo
		},
		{
			"Ad tapped",
			MoPubBase.LogLevel.MPLogLevelDebug
		},
		{
			"Ad expanded",
			MoPubBase.LogLevel.MPLogLevelDebug
		},
		{
			"Ad collapsed",
			MoPubBase.LogLevel.MPLogLevelDebug
		},
		{
			"Ad did disappear",
			MoPubBase.LogLevel.MPLogLevelDebug
		},
		{
			"Ad should reward user with {0} {1}",
			MoPubBase.LogLevel.MPLogLevelDebug
		},
		{
			"Ad expired since it was not shown fast enough",
			MoPubBase.LogLevel.MPLogLevelDebug
		}
	};

	public static void Log(string callerMethod, string message, params object[] args)
	{
		if (!logLevelMap.TryGetValue(message, out MoPubBase.LogLevel value))
		{
			value = MoPubBase.LogLevel.MPLogLevelDebug;
		}
		if (MoPubBase.logLevel <= value)
		{
			string text = "[MoPub-Unity] [" + callerMethod + "] " + message;
			try
			{
				UnityEngine.Debug.LogFormat(text, args);
			}
			catch (FormatException)
			{
				DebugUtils.Log(DebugType.Other, "Format exception while logging message { " + text + " } with arguments { " + string.Join(",", (from a in args
					select a.ToString()).ToArray()) + " }");
			}
		}
	}
}
